package com.interview.one.controller;

import com.interview.one.common.CommonRes;
import com.interview.one.domain.GetSignReq;
import com.interview.one.utils.YuanFenConverter;
import com.interview.one.utils.pay.PaySignUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/pay")
public class PayController {
    @PostMapping("/getPaySign")
    public CommonRes getPaySign(@RequestBody GetSignReq req) {
        try {
            return CommonRes.create((PaySignUtils.sign(YuanFenConverter.changeF2Y(String.valueOf(req.getTotalPrice())), req.getOrderId() + "")));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
